package com.wdh.kjs.fragment;

import android.app.ProgressDialog;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;
import android.widget.ScrollView;
import android.widget.TextView;

import com.google.gson.Gson;
import com.handmark.pulltorefresh.library.PullToRefreshBase;
import com.handmark.pulltorefresh.library.PullToRefreshListView;
import com.lidroid.xutils.HttpUtils;
import com.lidroid.xutils.exception.HttpException;
import com.lidroid.xutils.http.RequestParams;
import com.lidroid.xutils.http.ResponseInfo;
import com.lidroid.xutils.http.callback.RequestCallBack;
import com.lidroid.xutils.http.client.HttpRequest;
import com.wdh.kjs.Adapter.IM_investrecord_Adapter;
import com.wdh.kjs.Adapter.IM_raisesuccess_Adapter;
import com.wdh.kjs.Adapter.IM_raising_Adapter;
import com.wdh.kjs.Adapter.ListViewForScrollView;
import com.wdh.kjs.R;
import com.wdh.kjs.http.Httpurl;
import com.wdh.kjs.model.JsonModel_my;
import com.wdh.kjs.util.DateUtilChange;
import com.wdh.kjs.util.DateUtils;
import com.wdh.kjs.util.ToastUtils;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

/**
 * Created by chenqinhuang on 2016/4/3.
 */
public class Invest_manage_Fragment extends Fragment {

    private PullToRefreshListView listView;
    private IM_investrecord_Adapter IM_investrecord;
    private int listsize;
    private IM_raising_Adapter IM_raising;
    private IM_raisesuccess_Adapter IM_raise_two;

    private HashMap<String, String> maps = new HashMap<String, String>();
//    private ScrollView scrollView;
    public int QUERY_TYPE=0;
    private JsonModel_my jsonModel_my;
    private String partyId;
    private String m;
    private String time;
    public static int page ;
    public static int rows = 5;
    public static int totalrecords = 0;
    public static boolean mLoading = true;
    private List<HashMap<String, String>> datas;
    public static int iDisplayStart;
    public static int iDisplayLength = 5;
    private TextView tv_fragment_investmanage;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_investmanage_2, container, false);
        SharedPreferences sharedPreferences = getActivity().getSharedPreferences("logininfo", Context.MODE_PRIVATE);
        partyId = sharedPreferences.getString("loginToken", "");
        initView(view);


        loadData();
//        Log.i("msg","111");
        return view;
    }
    private void initView(View view) {
//        scrollView=(ScrollView)view.findViewById(R.id.fragment_investmanage_scrollview);
//        scrollView.smoothScrollTo(0, 0);
        listView=(PullToRefreshListView)view.findViewById(R.id.fragment_investmanage_listview);
        tv_fragment_investmanage = (TextView) view.findViewById(R.id.tv_fragment_investmanage);
    }
    private void loadData()
    {
        switch (QUERY_TYPE)
        {
            case 0:
                iDisplayStart=0;
                RequestParams params = new RequestParams();
                params.addBodyParameter("partyId", partyId);
                params.addBodyParameter("iDisplayStart", iDisplayStart+"");
                params.addBodyParameter("iDisplayLength",iDisplayLength+"");

                HttpUtils http = new HttpUtils();
                http.send(HttpRequest.HttpMethod.POST, Httpurl.URL_IM_INVESTRECORD, params, new RequestCallBack<String>() {
                    @Override
                    public void onSuccess(ResponseInfo<String> responseInfo) {
                        Gson gson = new Gson();
                        jsonModel_my = gson.fromJson(responseInfo.result, JsonModel_my.class);
                        totalrecords = jsonModel_my.getRecordsTotal();
                        if (jsonModel_my.success) {
                            if (totalrecords == 0) {
                                tv_fragment_investmanage.setVisibility(View.VISIBLE);
                            } else {
                                listsize = jsonModel_my.getAaData().size();
                                IM_investrecord = new IM_investrecord_Adapter(getContext(), initListViewData());
                                listView.setAdapter(IM_investrecord);
                                listView.setMode(PullToRefreshBase.Mode.PULL_FROM_END);
                                listView.setOnRefreshListener(new PullToRefreshBase.OnRefreshListener2<ListView>() {

                                    // 下拉Pulling Down
                                    @Override
                                    public void onPullDownToRefresh(PullToRefreshBase<ListView> refreshView) {
                                        // 下拉的时候数据重置
                                    }

                                    // 上拉Pulling Up
                                    @Override
                                    public void onPullUpToRefresh(PullToRefreshBase<ListView> refreshView) {
                                        // 上拉的时候添加选项

                                        String label = DateUtils.formatDateTime(getActivity().getApplicationContext(), System.currentTimeMillis(),
                                                DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_ABBREV_ALL);


                                        refreshView.getLoadingLayoutProxy().setLastUpdatedLabel(label);
                                        new MyGetDataTask().execute();


                                    }

                                });
                            }
                        }
                    }

                    @Override
                    public void onFailure(HttpException error, String msg) {
                        ToastUtils.showShort(getActivity(), "网络异常！");
                    }
                });

                break;
            case 1:
                page=1;
                RequestParams params_2 = new RequestParams();
                params_2.addBodyParameter("partyId", partyId);
                params_2.addBodyParameter("page", page+"");
                params_2.addBodyParameter("rows", rows+"");
                params_2.addBodyParameter("itemStatus", "7");

                HttpUtils http_2 = new HttpUtils();
                http_2.send(HttpRequest.HttpMethod.POST, Httpurl.URL_IM_RAISE, params_2, new RequestCallBack<String>() {
                    @Override
                    public void onSuccess(ResponseInfo<String> responseInfo) {
                        Gson gson = new Gson();
                        jsonModel_my = gson.fromJson(responseInfo.result, JsonModel_my.class);
                        if (jsonModel_my.success) {
                            totalrecords = jsonModel_my.getTotalrecords();
                            if (totalrecords == 0) {
                                tv_fragment_investmanage.setVisibility(View.VISIBLE);
                            } else {
                                IM_raising = new IM_raising_Adapter(getContext(), initListViewData());
                                listView.setAdapter(IM_raising);
                                listView.setMode(PullToRefreshBase.Mode.PULL_FROM_END);
                                listView.setOnRefreshListener(new PullToRefreshBase.OnRefreshListener2<ListView>() {

                                    // 下拉Pulling Down
                                    @Override
                                    public void onPullDownToRefresh(PullToRefreshBase<ListView> refreshView) {
                                        // 下拉的时候数据重置
                                    }

                                    // 上拉Pulling Up
                                    @Override
                                    public void onPullUpToRefresh(PullToRefreshBase<ListView> refreshView) {
                                        // 上拉的时候添加选项

                                        String label = DateUtils.formatDateTime(getActivity().getApplicationContext(), System.currentTimeMillis(),
                                                DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_ABBREV_ALL);


                                        refreshView.getLoadingLayoutProxy().setLastUpdatedLabel(label);
                                        new GetDataTask().execute();


                                    }

                                });
                            }
                        }
                    }
                    @Override
                    public void onFailure(HttpException error, String msg) {
                        ToastUtils.showShort(getActivity(), "网络异常！");
                    }
                });
                break;
            case 2:
                page=1;
                RequestParams params_3 = new RequestParams();
                params_3.addBodyParameter("partyId", partyId);
                params_3.addBodyParameter("page", page+"");
                params_3.addBodyParameter("rows", rows+"");
                params_3.addBodyParameter("itemStatus", "9");

                HttpUtils http_3 = new HttpUtils();
                http_3.send(HttpRequest.HttpMethod.POST, Httpurl.URL_IM_RAISE, params_3, new RequestCallBack<String>() {
                    @Override
                    public void onSuccess(ResponseInfo<String> responseInfo) {
                        Gson gson = new Gson();
                        jsonModel_my = gson.fromJson(responseInfo.result, JsonModel_my.class);
                        if (jsonModel_my.success) {
                            totalrecords = jsonModel_my.getTotalrecords();
                            if (totalrecords == 0) {
                                tv_fragment_investmanage.setVisibility(View.VISIBLE);
                            } else {
                                IM_raise_two = new IM_raisesuccess_Adapter(getContext(), initListViewData());
                                listView.setAdapter(IM_raise_two);
                                listView.setMode(PullToRefreshBase.Mode.PULL_FROM_END);
                                listView.setOnRefreshListener(new PullToRefreshBase.OnRefreshListener2<ListView>() {

                                    // 下拉Pulling Down
                                    @Override
                                    public void onPullDownToRefresh(PullToRefreshBase<ListView> refreshView) {
                                        // 下拉的时候数据重置
                                    }

                                    // 上拉Pulling Up
                                    @Override
                                    public void onPullUpToRefresh(PullToRefreshBase<ListView> refreshView) {
                                        // 上拉的时候添加选项

                                        String label = DateUtils.formatDateTime(getActivity().getApplicationContext(), System.currentTimeMillis(),
                                                DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_ABBREV_ALL);


                                        refreshView.getLoadingLayoutProxy().setLastUpdatedLabel(label);
                                        new GetDataTask().execute();


                                    }

                                });
                            }
                        }
                    }
                    @Override
                    public void onFailure(HttpException error, String msg) {
                        ToastUtils.showShort(getActivity(), "网络异常！");
                    }
                });
                break;
            case 3:
                page=1;
                RequestParams params_4 = new RequestParams();
                params_4.addBodyParameter("partyId", partyId);
                params_4.addBodyParameter("page", "1");
                params_4.addBodyParameter("rows", "5");
                params_4.addBodyParameter("itemStatus", "10");

                HttpUtils http_4 = new HttpUtils();
                http_4.send(HttpRequest.HttpMethod.POST, Httpurl.URL_IM_RAISE, params_4, new RequestCallBack<String>() {
                    @Override
                    public void onSuccess(ResponseInfo<String> responseInfo) {
                        Gson gson = new Gson();
                        jsonModel_my = gson.fromJson(responseInfo.result, JsonModel_my.class);
                        if (jsonModel_my.success) {
                            totalrecords = jsonModel_my.getTotalrecords();
                            if (totalrecords == 0) {
                                tv_fragment_investmanage.setVisibility(View.VISIBLE);
                            } else {
                                IM_raise_two = new IM_raisesuccess_Adapter(getContext(), initListViewData());
                                listView.setAdapter(IM_raise_two);
                                listView.setMode(PullToRefreshBase.Mode.PULL_FROM_END);
                                listView.setOnRefreshListener(new PullToRefreshBase.OnRefreshListener2<ListView>() {

                                    // 下拉Pulling Down
                                    @Override
                                    public void onPullDownToRefresh(PullToRefreshBase<ListView> refreshView) {
                                        // 下拉的时候数据重置
                                    }

                                    // 上拉Pulling Up
                                    @Override
                                    public void onPullUpToRefresh(PullToRefreshBase<ListView> refreshView) {
                                        // 上拉的时候添加选项

                                        String label = DateUtils.formatDateTime(getActivity().getApplicationContext(), System.currentTimeMillis(),
                                                DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_ABBREV_ALL);


                                        refreshView.getLoadingLayoutProxy().setLastUpdatedLabel(label);
                                        new GetDataTask().execute();


                                    }

                                });
                            }
                        }
                    }
                    @Override
                    public void onFailure(HttpException error, String msg) {
                        ToastUtils.showShort(getActivity(), "网络异常！");
                    }
                });
                break;
        }
    }
    private class MyGetDataTask extends AsyncTask<Void, Void, Void> {

        @Override
        protected Void doInBackground(Void... params) {

            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            if (totalrecords > datas.size()) {

                iDisplayStart += iDisplayLength;
                try {
                    getMore();

                } catch (Exception e) {
                    iDisplayStart -= iDisplayLength;
                    e.printStackTrace();
                }
            }
            return null;
        }

        @Override
        protected void onPostExecute(Void aVoid) {

            if (mLoading == false)
                ToastUtils.showShort(getActivity(), "已无更多数据！");
            listView.onRefreshComplete();

            super.onPostExecute(aVoid);

        }
    }

    private void getMore() {
        RequestParams params = new RequestParams();
        params.addBodyParameter("partyId", partyId);
        params.addBodyParameter("iDisplayStart", iDisplayStart+"");
        params.addBodyParameter("iDisplayLength",iDisplayLength+"");

        HttpUtils http = new HttpUtils();
        http.send(HttpRequest.HttpMethod.POST, Httpurl.URL_IM_INVESTRECORD, params, new RequestCallBack<String>() {
            @Override
            public void onSuccess(ResponseInfo<String> responseInfo) {
                Gson gson = new Gson();
                jsonModel_my = gson.fromJson(responseInfo.result, JsonModel_my.class);
                totalrecords = jsonModel_my.getRecordsTotal();
                if (jsonModel_my.success) {
                    listsize = jsonModel_my.getAaData().size();
                    for(int i=0;i<listsize;i++) {
                        HashMap<String, String> hashMap = new HashMap<>();

                        if (jsonModel_my.getAaData().get(i).getStatus().toString().equals("closed")) {
                            hashMap.put("investrecord_state", "订单关闭");
                        } else if (jsonModel_my.getAaData().get(i).getStatus().toString().equals("cancelled")) {
                            hashMap.put("investrecord_state", "订单取消");
                        } else if (jsonModel_my.getAaData().get(i).getStatus().toString().equals("unpaid")) {
                            hashMap.put("investrecord_state", "未支付");
                        } else if (jsonModel_my.getAaData().get(i).getStatus().toString().equals("paid")) {
                            hashMap.put("investrecord_state", "已支付");
                        } else if (jsonModel_my.getAaData().get(i).getStatus().toString().equals("needvoucher")) {
                            hashMap.put("investrecord_state", "待提供支付凭证");
                        } else if (jsonModel_my.getAaData().get(i).getStatus().toString().equals("unconfirmed")) {
                            hashMap.put("investrecord_state", "待确认");
                        } else if (jsonModel_my.getAaData().get(i).getStatus().toString().equals("invalid")) {
                            hashMap.put("investrecord_state", "订单失效");
                        }
                        ;

                        if (jsonModel_my.getAaData().get(i).getGdBenefitMode() == 0) {
                            hashMap.put("investrecord_repayType", "到期一次性还本付息");
                        } else if (jsonModel_my.getAaData().get(i).getGdBenefitMode() == 1) {
                            hashMap.put("investrecord_repayType", "按月付息到期还本");
                        }
                        ;

//                        int annualRate = new BigDecimal(jsonModel_my.getAaData().get(i).getGdAnnualizedBenefitRate().toString()).multiply(new BigDecimal(100 + "")).intValue();
                        DecimalFormat df = new DecimalFormat("0.00");
                        BigDecimal annualRate = new BigDecimal(jsonModel_my.getAaData().get(i).getGdAnnualizedBenefitRate().toString()).multiply(new BigDecimal(100 + ""));
                        String  newrate1=df.format(annualRate);
//                        String newrate1 = jsonModel_my.getAaData().get(i).getGdAnnualizedBenefitRate().toString();
                        hashMap.put("investrecord_name", jsonModel_my.getAaData().get(i).getItemName().toString());
                        hashMap.put("investrecord_annualRate", newrate1+"%" );
                        hashMap.put("investrecord_projectTime", jsonModel_my.getAaData().get(i).getInterestDays().toString() + "天");
                        hashMap.put("investrecord_orderNum", jsonModel_my.getAaData().get(i).getOrderId().toString());
                        hashMap.put("investrecord_investMoney", "￥" + new BigDecimal(jsonModel_my.getAaData().get(i).getTotalPrice().toString()).setScale(2) + "元");
                        hashMap.put("investrecord_time", jsonModel_my.getAaData().get(i).getPurchaseDate().toString().substring(0, 19));
                        hashMap.put("Id", jsonModel_my.getAaData().get(i).getOrderId());
                        datas.add(hashMap);
                    }
                    if (datas.size() == totalrecords)
                        mLoading = false;
                    IM_investrecord.notifyDataSetChanged();
                }
            }

            @Override
            public void onFailure(HttpException error, String msg) {
                ToastUtils.showShort(getActivity(), "网络异常！");
            }
        });

    }

    private class GetDataTask extends AsyncTask<Void, Void, Void> {

        @Override
        protected Void doInBackground(Void... params) {

            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            if (totalrecords > datas.size()) {

                page += 1;
                try {
                    getMoreList();

                } catch (Exception e) {
                    page -= 1;
                    e.printStackTrace();
                }
            }
            return null;
        }

        @Override
        protected void onPostExecute(Void aVoid) {

            if (mLoading == false)
                ToastUtils.showShort(getActivity(), "已无更多数据！");
            listView.onRefreshComplete();

            super.onPostExecute(aVoid);

        }
    }

    private void getMoreList() {
        RequestParams params_2 = new RequestParams();

        switch (QUERY_TYPE){
//            case 0:
//                params_2.addBodyParameter("partyId", partyId);
//                params_2.addBodyParameter("iDisplayStart", "0");
//                params_2.addBodyParameter("iDisplayLength","10");
            case 1:
                params_2.addBodyParameter("partyId", partyId);
                params_2.addBodyParameter("page", page+"");
                params_2.addBodyParameter("rows", rows+"");
                params_2.addBodyParameter("itemStatus", "7");;break;
            case 2:
                params_2.addBodyParameter("partyId", partyId);
                params_2.addBodyParameter("page", page+"");
                params_2.addBodyParameter("rows", rows+"");
                params_2.addBodyParameter("itemStatus", "9");
        break;
            case 3:
                params_2.addBodyParameter("partyId", partyId);
                params_2.addBodyParameter("page", page+"");
                params_2.addBodyParameter("rows", rows+"");
                params_2.addBodyParameter("itemStatus", "10");;break;
        }


        HttpUtils http_2 = new HttpUtils();
        http_2.send(HttpRequest.HttpMethod.POST, Httpurl.URL_IM_RAISE, params_2, new RequestCallBack<String>() {
            @Override
            public void onSuccess(ResponseInfo<String> responseInfo) {
                Gson gson = new Gson();
                jsonModel_my = gson.fromJson(responseInfo.result, JsonModel_my.class);
                if (jsonModel_my.success) {
                    totalrecords = jsonModel_my.getTotalrecords();
                    for(int i=0;i<jsonModel_my.getInvestitems().size();i++){
                        Log.i("msg","raise-111");
//                    String time = DateUtilChange.timestamp2String(jsonModel_my.getInvestitems().get(i).getInterestStartDate(),DateUtilChange.DEFAULT_DAY_FORMAT);
                        int annualRate = new BigDecimal(jsonModel_my.getInvestitems().get(i).getGdAnnualizedBenefitRate().toString()).multiply(new BigDecimal(100 + "")).intValue();

                        HashMap<String, String> hashMap = new HashMap<>();
                        hashMap.put("name", jsonModel_my.getInvestitems().get(i).getItemName().toString());
                        hashMap.put("annualRate",annualRate+"%");
                        hashMap.put("projectTime", jsonModel_my.getInvestitems().get(i).getInterestDays()+"天");

                        if(jsonModel_my.getInvestitems().get(i).getGdBenefitMode()== 0){
                            hashMap.put("repayType", "到期一次性还本付息");
                        }else if(jsonModel_my.getInvestitems().get(i).getGdBenefitMode()== 1)
                        { hashMap.put("repayType", "按月付息到期还本"); };

                        hashMap.put("totalMoney", "￥"+(int)jsonModel_my.getInvestitems().get(i).getTotalInvestment()+"元");

                        switch (QUERY_TYPE){
                            case 1:
                                hashMap.put("starttime", "-1");
                                hashMap.put("state", "募集中");
                                break;
                            case 2:
                                hashMap.put("starttime", time);
                                hashMap.put("state", jsonModel_my.getInvestitems().get(i).getGdBenefitReturnStep());
                        break;
                            case 3:
                                hashMap.put("starttime", "-1");
                                if (m.equals("0")){
                                    hashMap.put("state", "待退回");}
                                else {
                                    hashMap.put("state", "已退回");}break;
                        }

                        datas.add(hashMap);
                    }
                    if (datas.size() == totalrecords)
                        mLoading = false;
                    switch (QUERY_TYPE){
                        case 1:
                            IM_raising.notifyDataSetChanged();break;
                        case 2:
                    IM_raise_two.notifyDataSetChanged();
                            break;
                        case 3:
                            IM_raise_two.notifyDataSetChanged();break;
                    }

                }
            }
            @Override
            public void onFailure(HttpException error, String msg) {
                ToastUtils.showShort(getActivity(), "网络异常！");
            }
        });
    }

    private List<HashMap<String, String>> initListViewData()
    {
        datas=new ArrayList<>();
        switch (QUERY_TYPE)
        {
            case 0:
                for(int i=0;i<listsize;i++){
                    HashMap<String, String> hashMap = new HashMap<>();

                    if(jsonModel_my.getAaData().get(i).getStatus().toString().equals("closed")){
                        hashMap.put("investrecord_state", "订单关闭");
                    }else if(jsonModel_my.getAaData().get(i).getStatus().toString().equals("cancelled"))
                    { hashMap.put("investrecord_state", "订单取消"); }
                    else  if(jsonModel_my.getAaData().get(i).getStatus().toString().equals("unpaid"))
                    { hashMap.put("investrecord_state", "未支付"); }
                    else if(jsonModel_my.getAaData().get(i).getStatus().toString().equals("paid"))
                    { hashMap.put("investrecord_state", "已支付"); }
                    else  if(jsonModel_my.getAaData().get(i).getStatus().toString().equals("needvoucher"))
                    { hashMap.put("investrecord_state", "待提供支付凭证"); }
                    else if(jsonModel_my.getAaData().get(i).getStatus().toString().equals("unconfirmed"))
                    { hashMap.put("investrecord_state", "待确认"); }
                    else if(jsonModel_my.getAaData().get(i).getStatus().toString().equals("invalid"))
                    { hashMap.put("investrecord_state", "订单失效"); };

                    if(jsonModel_my.getAaData().get(i).getGdBenefitMode()== 0){
                        hashMap.put("investrecord_repayType", "到期一次性还本付息");
                    }else if(jsonModel_my.getAaData().get(i).getGdBenefitMode()== 1)
                    { hashMap.put("investrecord_repayType", "按月付息到期还本"); };

//                    int annualRate = new BigDecimal(jsonModel_my.getAaData().get(i).getGdAnnualizedBenefitRate().toString()).multiply(new BigDecimal(100 + "")).intValue();
                    DecimalFormat df = new DecimalFormat("0.00");
                    BigDecimal annualRate = new BigDecimal(jsonModel_my.getAaData().get(i).getGdAnnualizedBenefitRate().toString()).multiply(new BigDecimal(100 + ""));
                    String  newrate1=df.format(annualRate);

//                    String newrate1 = jsonModel_my.getAaData().get(i).getGdAnnualizedBenefitRate().toString();
                    hashMap.put("investrecord_name", jsonModel_my.getAaData().get(i).getItemName().toString());
                    hashMap.put("investrecord_annualRate",newrate1+"%");
                    hashMap.put("investrecord_projectTime", jsonModel_my.getAaData().get(i).getInterestDays().toString()+"天");
                    hashMap.put("investrecord_orderNum", jsonModel_my.getAaData().get(i).getOrderId().toString());
                    hashMap.put("investrecord_investMoney", "￥"+new BigDecimal(jsonModel_my.getAaData().get(i).getTotalPrice().toString()).setScale(2)+"元");
                    hashMap.put("investrecord_time", jsonModel_my.getAaData().get(i).getPurchaseDate().toString());
                    hashMap.put("Id", jsonModel_my.getAaData().get(i).getOrderId());
                    hashMap.put("investrecord_itemId", jsonModel_my.getAaData().get(i).getItemId().toString());
                    hashMap.put("money", jsonModel_my.getAaData().get(i).getTotalPrice());
                    datas.add(hashMap);
                }
                break;
            case 1:
                for(int i=0;i<jsonModel_my.getInvestitems().size();i++){
                    Log.i("msg","raise-111");
//                    String time = DateUtilChange.timestamp2String(jsonModel_my.getInvestitems().get(i).getInterestStartDate(),DateUtilChange.DEFAULT_DAY_FORMAT);
                    DecimalFormat df = new DecimalFormat("0.00");
                    BigDecimal annualRate = new BigDecimal(jsonModel_my.getInvestitems().get(i).getGdAnnualizedBenefitRate().toString()).multiply(new BigDecimal(100 + ""));
                    String  newrate1=df.format(annualRate);
                    HashMap<String, String> hashMap = new HashMap<>();
                    hashMap.put("name", jsonModel_my.getInvestitems().get(i).getItemName().toString());
                    hashMap.put("annualRate",newrate1+"%");
                    hashMap.put("projectTime", jsonModel_my.getInvestitems().get(i).getInterestDays()+"天");

                    if(jsonModel_my.getInvestitems().get(i).getGdBenefitMode()== 0){
                        hashMap.put("repayType", "到期一次性还本付息");
                    }else if(jsonModel_my.getInvestitems().get(i).getGdBenefitMode()== 1)
                    { hashMap.put("repayType", "按月付息到期还本"); };

                    hashMap.put("totalMoney", "￥"+(int)jsonModel_my.getInvestitems().get(i).getTotalInvestment()+"元");
                    hashMap.put("state", "募集中");
                    hashMap.put("starttime", "-1");
                    datas.add(hashMap);
                }
                break;
            case 2:
                for(int i= 0;i<jsonModel_my.getInvestitems().size();i++){
                    if (jsonModel_my.getInvestitems().get(i).getInterestStartDate()!=0){
                     time = DateUtilChange.timestamp2String(jsonModel_my.getInvestitems().get(i).getInterestStartDate(),DateUtilChange.DEFAULT_DAY_FORMAT);}
                    else {
                        time = "——";
                    }
                    DecimalFormat df = new DecimalFormat("0.00");
                    BigDecimal annualRate = new BigDecimal(jsonModel_my.getInvestitems().get(i).getGdAnnualizedBenefitRate().toString()).multiply(new BigDecimal(100 + ""));
                    String  newrate1=df.format(annualRate);
                    HashMap<String, String> hashMap = new HashMap<>();
                    hashMap.put("name", jsonModel_my.getInvestitems().get(i).getItemName().toString());
                    hashMap.put("annualRate", newrate1+"%");
                    hashMap.put("projectTime", jsonModel_my.getInvestitems().get(i).getInterestDays()+"天");

                    if(jsonModel_my.getInvestitems().get(i).getGdBenefitMode()== 0){
                        hashMap.put("repayType", "到期一次性还本付息");
                    }else if(jsonModel_my.getInvestitems().get(i).getGdBenefitMode()== 1)
                    { hashMap.put("repayType", "按月付息到期还本"); };

                    hashMap.put("totalMoney", "￥"+(int)jsonModel_my.getInvestitems().get(i).getTotalInvestment()+"元");
                    hashMap.put("state", jsonModel_my.getInvestitems().get(i).getGdBenefitReturnStep());
                    hashMap.put("starttime", time);
                    datas.add(hashMap);
                }
                break;
            case 3:
                for(int i= 0;i<jsonModel_my.getInvestitems().size();i++){
//                    String time = DateUtilChange.timestamp2String(jsonModel_my.getInvestitems().get(i).getInterestStartDate(),DateUtilChange.DEFAULT_DAY_FORMAT);
                    BigDecimal annualRate = new BigDecimal(jsonModel_my.getInvestitems().get(i).getGdAnnualizedBenefitRate().toString()).multiply(new BigDecimal(100 + ""));
                    DecimalFormat df = new DecimalFormat("0.00");
                    String  newrate1=df.format(annualRate);
                     m = jsonModel_my.getInvestitems().get(i).getInvestDelFlag();
                    HashMap<String, String> hashMap = new HashMap<>();
                    hashMap.put("name", jsonModel_my.getInvestitems().get(i).getItemName().toString());
                    hashMap.put("annualRate", newrate1+"%");
                    hashMap.put("projectTime", jsonModel_my.getInvestitems().get(i).getInterestDays()+"天");

                    if(jsonModel_my.getInvestitems().get(i).getGdBenefitMode()== 0){
                        hashMap.put("repayType", "到期一次性还本付息");
                    }else if(jsonModel_my.getInvestitems().get(i).getGdBenefitMode()== 1)
                    { hashMap.put("repayType", "按月付息到期还本"); };

                    hashMap.put("totalMoney", "￥"+(int)jsonModel_my.getInvestitems().get(i).getTotalInvestment()+"元");
                    if (m.equals("0")){
                    hashMap.put("state", "待退回");}
                    else {
                        hashMap.put("state", "已退回");}
                    hashMap.put("starttime", "-1");
                    datas.add(hashMap);
                }
                break;
        }

        return datas;
    }


}
